import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { WebsiteVO, WebsiteForm, WebsiteQuery } from '@/api/logic/website/types';

/**
 * 查询站点管理列表
 * @param query
 * @returns {*}
 */

export const listWebsite = (query?: WebsiteQuery): AxiosPromise<WebsiteVO[]> => {
  return request({
    url: '/logic/website/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询站点管理详细
 * @param websiteId
 */
export const getWebsite = (websiteId: string | number): AxiosPromise<WebsiteVO> => {
  return request({
    url: '/logic/website/' + websiteId,
    method: 'get'
  });
};

/**
 * 新增站点管理
 * @param data
 */
export const addWebsite = (data: WebsiteForm) => {
  return request({
    url: '/logic/website',
    method: 'post',
    data: data
  });
};

/**
 * 修改站点管理
 * @param data
 */
export const updateWebsite = (data: WebsiteForm) => {
  return request({
    url: '/logic/website',
    method: 'put',
    data: data
  });
};

/**
 * 删除站点管理
 * @param websiteId
 */
export const delWebsite = (websiteId: string | number | Array<string | number>) => {
  return request({
    url: '/logic/website/' + websiteId,
    method: 'delete'
  });
};

/**
 * 发布站点
 * @param websiteId
 */
export const publishWebsite = (websiteId: string | number) => {
  return request({
    url: `/logic/website/pub/${websiteId}`,
    method: 'post'
  });
};
